package PlugIn;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author      Erwan Osouf, Lucas Ennouchi
 * @version     1.0                                
 * @since       29/01/2012
 */

public class PlugInControl implements ActionListener{
	
	
	private PlugInUI view;
	private PlugInModel abstraction;
	
	/**
	 * Constructor
	 * @param view the view to be attached 
	 * @param abstraction the model
	 */
	public PlugInControl(PlugInUI view, PlugInModel abstraction) {
		super();
		this.view = view;
		this.abstraction = abstraction;
	}

	/**
	 * getter to get the view
	 * @return view
	 */
	public PlugInUI getView() {
		return view;
	}

	/**
	 * getter to get the abstraction
	 * @return abstraction
	 */
	public PlugInModel getAbstraction() {
		return abstraction;
	}

	@Override
	/**
	 * action performed when we click on the command
	 */
	public void actionPerformed(ActionEvent e) {
		abstraction.run();
		view.setCommandResult(abstraction.getResult());	
	}
	
}
